<?php

    $card_id = $mikron->Cache->getCache('patient_cardid');
    $ticket_id = $mikron->Cache->getCache('ticketid');
    
    if(!$mikron->Tools->IsNullOrEmpty($card_id) && !$mikron->Tools->IsNullOrEmpty($ticket_id))
    {
        $record = new record_class($card_id, $ticket_id);
    }

    class record_class
    {
        public $cardid = '';
        public $ticketid = '';
        public $errorcode = '';
        public $errortext = '';
        public function __construct($cardid, $ticketid)
        {
            $this->cardid = $cardid;
            $this->ticketid = $ticketid;
            $xml = CreateDoRegistryXML($cardid, $ticketid);
            $xmlfile = CallSoap('doregistry', $xml);
            // XML с данными расписания
            $dom1 = new DomDocument();
            $dom1->loadXML($xmlfile);
            $infomat = $dom1->getElementsByTagName('infomat');
            // Заполнение классов из XML
            foreach($infomat as $item)
            {
                $this->errorcode = $item->getAttribute('errorcode');
                if($this->errorcode <> 0)
                {
                    $errors = $item->getElementsByTagName("error");
                    // Заполнение классов из XML
                    foreach($errors as $erroritem)
                    {
                        $errortext = $erroritem->nodeValue;
                        // $errortext = i conv("UTF-8", "WINDOWS-1251", $errortext);
                        $this->errortext = $errortext;
                    }
                }
            }
        }
    }
?>